﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int IsLogin = Convert.ToInt32(Session["IsLogin"]);
        if (IsLogin!=0)
        {
            IsLogin = 0;
            Session["IsLogin"] = IsLogin;
        }
        Session["UserId"] = "";
        //FLogin.Attributes.Add("Value", "用户名");                                                       //用户名提示语点击后取消
        //FLogin.Attributes.Add("OnFocus", "if(this.value=='用户名') {this.value=''}");
        //FLogin.Attributes.Add("OnBlur", "if(this.value==''){this.value='用户名'}");

        //FPass.Attributes.Add("Value", "密码");                                                    //密码提示语点击后取消
        //FPass.Attributes.Add("OnFocus", "if(this.value=='密码'){this.value=''}");
        //FPass.Attributes.Add("OnBlur", "if(this.value==''){this.value='密码'}");

    }

    protected void IBtLogin_Click(object sender, EventArgs e)
    {
        GridView1.DataBind();
        SqlDataSource1.DataBind();
        int r = GridView1.PageCount;
        if (r == 1)
        {
            int type = System.Convert.ToInt16(DropDownList1.SelectedValue);
            
            //Session["Message"] = "您已成功登录";
            if (type == 1)
            {
                Session["UserId"] = FLogin.Text.Trim().ToString(); ;
                Session["IsLogin"] = 2;
                Response.Redirect("Admin.aspx"); 
            }
            else
            {
                Session["IsLogin"] = 1;
                Session["UserId"] = FLogin.Text.Trim().ToString();
                Response.Redirect("Repair.aspx");  
            }
        }
        else
        {
            Label1.Text = "<p><font color='red'>用户名或密码错误</font></p>";
        }
    }
}